package org.example.classloader;

/**
 * 初始化顺序执行
 * 1. 静态代码块
 * 2. 静态变量
 * 3. 构造方法
 * 输出：
 * Static block executed during initialization.
 * Static field initialized.
 * Main method started.
 * Constructor called.
 */
public class LoaderOrderDemo {
    static {
        System.out.println("Static block executed during initialization.");
    }

    static int staticField = initializeStaticField();

    private static int initializeStaticField() {
        System.out.println("Static field initialized.");
        return 10;
    }

    public LoaderOrderDemo() {
        System.out.println("Constructor called.");
    }

    public static void main(String[] args) {
        System.out.println("Main method started.");
        LoaderOrderDemo obj = new LoaderOrderDemo();
    }
}